#ifndef LANGUAGE_MODEL_H
#define LANGUAGE_MODEL_H

#include <QAbstractTableModel>
#include <QVector>
#include "LanguageElement.h"

class LanguageModel : public QAbstractTableModel
{
    Q_OBJECT
    
public:

    explicit LanguageModel(QObject *parent = 0);
    
    virtual int rowCount( const QModelIndex & index ) const
    {
        if( index.isValid() )
        {
            return 0;
        }
        
        return languageElementTable.size();
    }
    
    virtual int columnCount( const QModelIndex & index ) const
    {
        Q_UNUSED( index );
        
        return 3;
    }
    
    bool isModified() const { return modified; }
    
    virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const;
    virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);

    int getRowIndex( int symbol_index );
    bool rowIsComplete( int symbol_index );

	const QVector<LanguageElement> & getLanguageElementTable() const { return languageElementTable; }
	void initializeModel( const QVector<LanguageElement> & language_element_table );
    
signals:

    void contentsChanged();
    
private:

    void setModified();

    QVector<LanguageElement> languageElementTable;
    int currentIndex; //next available unique index
    bool modified;

};

#endif
